using System;
using System.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Contexts;
using System.Runtime.Remoting.Messaging;

namespace Skynet.CommonLibrary.AOP.AOPBase
{
    internal sealed class AOPProperty : IContextProperty, IContributeObjectSink
	{
        private IMessageSink CreateSink(IMessageSink nextSink)
        {
            return new AopSink(nextSink);
        }

		private string GetName()
		{
			return "AOP";
		}

		private void FreezeImpl(Context newContext)
		{
			return;
		}

        private bool CheckNewContext(Context newCtx)
		{
			return true;
		}

		#region IContributeObjectSink Members

		public IMessageSink GetObjectSink(MarshalByRefObject obj, IMessageSink nextSink)
		{
			return CreateSink(nextSink);
		}

		#endregion

		#region IContextProperty Members

		public void Freeze(Context newContext)
		{
			FreezeImpl(newContext);
		}

		public bool IsNewContextOK(Context newCtx)
		{
			return CheckNewContext(newCtx);
		}

		public string Name
		{
			get { return GetName(); }
		}

		#endregion
	}
}
